﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Reflection;

namespace time
{
    class Class_js2
    {
        public static void dowork()
        {

            Console.WriteLine(GetTemp());
        }


        private static string GetTemp()
        {

            System.Type type = System.Type.GetTypeFromProgID("MSScriptControl.ScriptControl");
            Object script = System.Activator.CreateInstance(type);
            type.InvokeMember("language", BindingFlags.SetProperty, null, script, new Object[] { "JavaScript" });
            //type.InvokeMember("AddCode", BindingFlags.InvokeMethod, null, script, new Object[] { "function test(){ return new Date().getTime().toString(36)}" });
            //return type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "test" }).ToString();

            //StreamReader sr = new StreamReader("1.js");
            //string s = sr.ReadToEnd();
            //type.InvokeMember("AddCode", BindingFlags.InvokeMethod, null, script, new Object[] { s });
            //string o = type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "a" }).ToString();
            //string o = type.InvokeMember("run(a)", BindingFlags.InvokeMethod, null, script, new Object[] {  }).ToString();
            //string o = type.InvokeMember("run", BindingFlags.InvokeMethod, null, script, new Object[] {"a","11" }).ToString();
            
            
            //return o.ToString();

            StreamReader sr = new StreamReader("ps.js");
            string s = sr.ReadToEnd();
            ////sr = new StreamReader("overlib.js");
            ////s += "\n";
            ////s += sr.ReadToEnd();

            ////sr = new StreamReader("ping.js");
            ////s += "\n";
            ////s += sr.ReadToEnd();

            ////sr = new StreamReader("ps.js");
            ////s += "\n";
            ////s += sr.ReadToEnd();


            type.InvokeMember("AddCode", BindingFlags.InvokeMethod, null, script, new Object[] { s });


            return type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "hex_hmac_md5", "'aR!@$34GP<S#@Js;", "111111" }).ToString();

        }

    }


}
